package javabase.schoolwork.day7_13.d13.d13;

import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

public class Test1 {
	Random random;
	ArrayList<Student> stuList;
	@Before
	public void init() {
		random=new Random();
		stuList=new ArrayList<Student>() {
			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			{
				for(int i=0;i<100;i++) {
					add(new Student("student"+i,random.nextInt()+50));
				}
			}
		};
	}
	
	@Test
	public void fun1() {
		List<String> studentList=stuList.stream().filter(x->x.getScore()>85)
				.sorted(Comparator.comparing(Student::getScore).reversed()).map(Student::getName)
				.collect(Collectors.toList());
		System.out.println(studentList);
	}
}
